<template>
	<contents
		:heightInclude="['tabBar']"
		class="address_page"
		:nullData="addressList.length === 0"
		:nullText="$t('locales.notAddres')"
		nullImg="../../../static/images/null_address.png"
	>
		<AddressItem
			v-for="item in addressList"
			:key="item.id"
			:value="item"
			@change="getData"
		/>
		<SubmitBtn @click="newAddress" :text="$t('locales.newAddress')" />
	</contents>
</template>

<script>
import SubmitBtn from '@/components/submitBtn'
import AddressItem from '@/components/addressItem'
import { addressList } from '@/api/http/user'
export default {
	components: {
		SubmitBtn,
		AddressItem
	},
	props: {},
	data() {
		return {
			addressList: []
		}
	},
	onLoad() {
		
	},
	onShow() {
		this.getData()
	},
	methods: {
		getData() {
			addressList({ pageNo: 1, pageSize: 100 }).then(res => {
				if (res.code === 200) {
					this.addressList = res.data.records
				} else {
					uni.showToast({
						icon: 'none',
						title: res.message
					})
				}
			})
		},
		newAddress() {
			uni.navigateTo({
				url: '/pages/user/address/newAddress'
			})
		}
	}
}
</script>

<style lang="scss" scoped></style>
